package p700;

import java.util.Arrays;

public class Leetcode_724 {
    public int pivotIndex(int[] nums) {
        int sum = Arrays.stream(nums).sum();
        int m_sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if(m_sum * 2 == sum - nums[i]){
                return i;
            }
            m_sum += nums[i];
        }
        return -1;
    }

    public static void main(String[] args) {
        Leetcode_724 l = new Leetcode_724();
        System.out.println(l.pivotIndex(new int[]{1,7,3,6,5,6}));
    }
}
